package com.baidu.dao;

import com.baidu.pojo.Assess;
import com.baidu.pojo.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface AssessMapper {
    //查询所有用户评论
    @Select("SELECT * FROM assess")
    public List<Assess> getAllAssesss();
    //删除用户评论
    @Update("UPDATE assess set astate=1 where aid=#{aid}")
    public void deleteAssess(Integer aid);
    public List<Assess> getAssessByEid(Integer eid);
//  查询评论
    public List<Assess> getAssessByUid(Integer uid);
//    修改评论
    @Update("UPDATE assess SET acontent=#{acontent},atime=#{atime} WHERE aid=#{aid}")
    public void updateAssessByAid(Assess assess);
//    删除评论
    @Update("UPDATE assess SET astate=1 WHERE aid=#{aid}")
    public void delAssessByAid(Integer aid);
//    添加评论
    @Insert("INSERT INTO assess(uid,eid,acontent,atime,astate) VALUES(#{uid},#{eid},#{acontent},#{atime},0)")
    public void addAssess(Assess assess);
    //分页查询总记录数
    @Select("select COUNT(*) from assess where astate!=1 ")
    public int count();
    public List<Assess> getByPage(@Param("start")Integer start, @Param("pageSize")Integer pageSize);
    @Select("select COUNT(*) from assess where astate!=1 and uid = #{uid}")
    public Integer getAllAssessByUIdCount(Integer uid);
    public List<Assess> getAllAssessByUIdByPage(@Param("start")Integer start, @Param("pageSize")Integer pageSize, @Param("uid")Integer uid);
}
